//
//  Contact.m
//  ContactViewerIos
//
//  Created by ANDY SELVIG on 3/7/12.
//  Copyright (c) 2012 Tiny Mission. All rights reserved.
//

#import "Contact.h"

@implementation Contact

NSString * const NAME_KEY = @"name";
NSString * const PHONE_KEY = @"phone";
NSString * const TITLE_KEY = @"title";
NSString * const EMAIL_KEY = @"email";
NSString * const TWITTER_ID_KEY = @"twitterID";

@synthesize name, title, email, phone, twitterId;

-(id)initWithName:(NSString*)newName 
        andPhone:(NSString*)newPhone
        andTitle:(NSString*)newTitle 
        andEmail:(NSString*)newEmail
        andTwitterId:(NSString*)newTwitterId {
    
    self = [super init];
    
    self.name = newName;
    self.phone = newPhone;
    self.title = newTitle;
    self.email = newEmail;
    self.twitterId = newTwitterId;
    
    return self;
}

-(id) initFromDictionary:(NSDictionary*) dictionary
{
    self = [super init];
    self.name =      [dictionary objectForKey:NAME_KEY];
    self.phone =     [dictionary objectForKey:PHONE_KEY];
    self.title =     [dictionary objectForKey:TITLE_KEY];
    self.email =     [dictionary objectForKey:EMAIL_KEY];
    self.twitterId = [dictionary objectForKey:TWITTER_ID_KEY];
    
    return self;
}

-(NSDictionary*)toDictionary {
    NSDictionary* info = [NSDictionary dictionaryWithObjectsAndKeys:
                          self.name,      NAME_KEY,
                          self.phone,     PHONE_KEY,
                          self.title,     TITLE_KEY,
                          self.email,     EMAIL_KEY,
                          self.twitterId, TWITTER_ID_KEY,
                          nil];
    return info;
}

@end
